package cn.yto.wdgj.wdgjgptdigitaltool.controller;

import cn.yto.response.BaseResponse;
import cn.yto.response.DataResult;
import cn.yto.wdgj.common.reponse.MutiResponse;
import cn.yto.wdgj.wdgjgptdigitaltool.entity.dto.request.GptCaseMaintenanceRequest;
import cn.yto.wdgj.wdgjgptdigitaltool.entity.dto.request.GptTagMaintenanceRequest;
import cn.yto.wdgj.wdgjgptdigitaltool.entity.dto.response.GptCaseMaintenanceResponse;
import cn.yto.wdgj.wdgjgptdigitaltool.entity.dto.response.GptTagMaintenanceResponse;
import cn.yto.wdgj.wdgjgptdigitaltool.service.GptTagMaintenanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping(value = "/tag")
@Api(value = "匹配方式", tags = {"匹配方式"})
public class GptTagMaintenanceController {
    @Autowired
    private GptTagMaintenanceService gptTagMaintenanceService;

    @RequestMapping(value = "/del", method = RequestMethod.GET)
    @ApiOperation(value = "删除匹配方式", httpMethod = "GET", notes = "删除匹配方式")
    public DataResult<BaseResponse> del(@RequestParam("id") Long tagId) {
        try {
            return gptTagMaintenanceService.delTagCaseMaintenance(tagId);
        } catch (Exception e) {
            log.error("/del", e);
            return DataResult.fail(e.getMessage());
        }
    }
    @RequestMapping(value = "/getPage", method = RequestMethod.POST)
    @ApiOperation(value = "分页查询匹配方式", httpMethod = "POST", notes = "分页查询匹配方式")
    public DataResult<MutiResponse<GptTagMaintenanceResponse>> getPage(@RequestBody GptTagMaintenanceRequest gptTagMatcherRequest) {
        try {
            return gptTagMaintenanceService.getAllGptTagMaintenance(gptTagMatcherRequest);
        } catch (Exception e) {
            log.error("/getPage", e);
            return DataResult.fail(e.getMessage());
        }
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ApiOperation(value = "保存匹配方式", httpMethod = "POST", notes = "保存匹配方式")
    public DataResult<BaseResponse> save(@RequestBody GptTagMaintenanceRequest gptTagMatcherRequest){
        try {
            return gptTagMaintenanceService.saveGptTagMaintenance(gptTagMatcherRequest);
        } catch (Exception e) {
            log.error("/save", e);
            return DataResult.fail(e.getMessage());
        }

    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ApiOperation(value = "更新匹配方式", httpMethod = "POST", notes = "更新匹配方式")
    public DataResult<BaseResponse> update(@RequestBody GptTagMaintenanceRequest gptTagMatcherRequest){
        try {
            return gptTagMaintenanceService.updateGptTagMaintenance(gptTagMatcherRequest);
        } catch (Exception e) {
            log.error("/update", e);
            return DataResult.fail(e.getMessage());
        }
    }

}
